package leetcode.每日一题;

import org.junit.Test;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

/**
 * @author :songyaozhang
 * @date :Created 2021/7/13 10:01
 * @description :https://leetcode-cn.com/problems/intersection-of-two-linked-lists/
 */


public class 相交链表 {
    @Test
    public void test() {
        //Solution solution = new Solution();

    }


    //Definition for singly-linked list.
    public class ListNode {
        int val;
        ListNode next;
        ListNode(int x) {
            val = x;
            next = null;
        }
    }

    /*
    public class Solution {
        public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            HashSet<ListNode> set = new HashSet<>();
            ListNode tmpA = headA;
            ListNode tmpB = headB;
            while (tmpA != null) {
                set.add(tmpA);
                tmpA = tmpA.next;
            }
            while (tmpB != null) {
                if (!set.add(tmpB)) {
                    return tmpB;
                }
                tmpB = tmpB.next;
            }
            return null;
        }
    }
     */
    /*
    public class Solution {
        public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            if (headA == null || headB == null) return null;
            ListNode pA = headA;
            ListNode pB = headB;
            while (pA != pB) {
                pA = pA == null ? pB : pA.next;
                pB = pB == null ? pA : pB.next;
            }
            return null;
        }
    }
     */

}
